
public class Square {
	// 异常处理
	private double num;

	public double getNum() {
		return num;
	}

	public void setNum(double num) {
		this.num = num;
	}

	public Square() {

		this.num = num;
	}

	public void square(double num) throws MyException {

		if (num >= 0) {
			System.out.println("对" + num + "进行开方");
			System.out.println(Math.sqrt(num));
		} else {

			throw new MyException(num);
		}

	}

}
